<?php

class SourceDocumentsController extends AppController {

    public $scaffold;
    public $paginate;
    public $components = array(
        'ExtendedScaffold.ScaffoldUtil' => array(
            'editUnsetFields' => array(
                'tagged',
            ),
            'viewSetFields' => array(
                '_extended' => array(
                    array(
                        'label' => 'Principal',
                        'lines' => array(
                            'name'
                        )
                    ),
                    array(
                        'label' => 'Raw Files',
                        'listAssociation' => 'RawFile',
                        'lines' => array(
                            'name'
                        )
                    ),
                    array(
                        'label' => 'Tags',
                        'listAssociation' => 'SourceDocumentTag',
                        'lines' => array(
                            'Tag.name'
                        )
                    )
                )
            )
        )
    );
    public $notModuleActions = array(
        'add',        
        'delete',
    );

    public function getPaginatorUtilFilters() {
        return array(
            'Name' => array(
                'conditions' => "SourceDocument.name like concat(?,'%')"
            ),
            'Tagged' => array(
                'conditionsPerValue' => array(
                    __('Yes', true) => $this->SourceDocument->getVirtualField('tagged'),
                    __('No', true) => 'not '.$this->SourceDocument->getVirtualField('tagged'),
                ),
            ),
        );
    }

}
